@echo off
rm ../embeded.h
rm libembeded.a

echo #ifndef EMBEDED_H > .\..\embeded.h
echo #define EMBEDED_H >> .\..\embeded.h
echo //////////////////////////////////////////////// >> .\..\embeded.h

for /f %%a IN ('dir /b .\Files\*.*') do @echo Embedding %%a ... & ^
ld -r -b binary -o .\Resources\%%a.o .\Files\%%a & @echo //Symbols for %%a >> .\..\embeded.h & ^
for /f "tokens=1-5 delims=/ " %%r IN ('nm -gC .\Resources\%%a.o') do @echo extern char %%t[]; >> .\..\embeded.h

echo #endif >> .\..\embeded.h

set myvar=

for /f %%g IN ('dir /b .\Resources\*.*') do call :concat %%g
set myvar=%myvar:; = %
set myvar=%myvar:~1,-1%
cd Resources
..\ld -r %myvar% -o ..\libembeded.a
cd ..

goto :eof
:concat
set myvar=%myvar% %1;
goto :eof